package com.disgruntledbots;

import java.util.ArrayList;

import org.andengine.engine.handler.IUpdateHandler;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class ReplayUpdateHandler implements IUpdateHandler{

	JSONObject replayData;
	ArrayList<PhysicsEntityConnector> mObjects;
	MultiplayerActivity mParent;
	ReplayPhysicsUpdater updater;
	
	public ReplayUpdateHandler(MultiplayerActivity parent)
	{
		this.mParent = parent;
		this.mObjects = parent.physicsObjects;
		updater = null;
	}
	
	@Override
	public void onUpdate(float pSecondsElapsed) {
		if(updater != null)
		{
			updater.update();
			if(updater.done)
			{
				updater = null;
			}
		}
	}

	@Override
	public void reset() {
		// TODO Auto-generated method stub
		
	}

	public void startReplay(JSONObject replay)
	{
		updater = new ReplayPhysicsUpdater(replay, mObjects);
	}
}
